﻿using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using MS.InformationManagement.WP.DocumentCenter.Contracts.Search;
using MS.InformationManagement.DAL.DocumentCenter;

namespace MS.InformationManagement.WP.DocumentCenter.SearchRefinementPanel
{
    [ToolboxItemAttribute(false)]
    public class SearchRefinementPanel : WebPart, ISearchFilterProvider
    {
        #region [ISearchFilterProvider members]
        SearchConfig ISearchFilterProvider.SearchConfig
        {
            get { return _SearchRefinementPanelUserControl != null ? _SearchRefinementPanelUserControl.SelectedSearchHistoryItem : null; }
        }
        #endregion

        // Visual Studio might automatically update this path when you change the Visual Web Part project item.
        private const string _ascxPath = @"~/_CONTROLTEMPLATES/MS.InformationManagement.WP.DocumentCenter/SearchRefinementPanel/SearchRefinementPanelUserControl.ascx";
        private SearchRefinementPanelUserControl _SearchRefinementPanelUserControl;

        protected override void CreateChildControls()
        {
            _SearchRefinementPanelUserControl = Page.LoadControl(_ascxPath) as SearchRefinementPanelUserControl;
            Controls.Add(_SearchRefinementPanelUserControl);
        }

        [ConnectionProvider("Selected Filter")]
        public ISearchFilterProvider SearchFilterProvider()
        {
            return this;
        }


    }
}
